package com.examiner.controller;

import com.examiner.bean.vo.MyTestAndTestDBVo;
import com.examiner.page.QueryInfo;
import com.examiner.result.Result;
import com.examiner.service.SelectService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("selectTest")
public class SelectTestController {
    @Resource
    private SelectService selectService;

    // 获取其本身及下级的所有的考评记录
    @PostMapping("/getSelectTestList/{uid}")
    public Result<Object> getSelectTestList(@PathVariable("uid")Integer uid, @RequestBody QueryInfo queryInfo){
        List<MyTestAndTestDBVo> myTestList;
        int total;
        Map<String, Object> data = new HashMap<>();
        try{
            myTestList = selectService.getSelectTestList(uid, queryInfo);
            total = selectService.getSelectTestListTotal(uid,queryInfo);
        }catch (Exception e){
            e.printStackTrace();
            return Result.RESULT(201,"获取考评记录失败",false,null);
        }
        data.put("myTestList",myTestList);
        data.put("total",total);
        return Result.RESULT(200,"成功获取考评记录",true,data);
    }
}
